﻿namespace Oblivion.Networking.Packets
{
    public class PayloadPacket
    {
        #region PayloadType enum

        public enum PayloadType
        {
            InitialSpawn = 0,
            Respawn = 1
        }

        #endregion

        private readonly Packet pkt;
        public PayloadType Type;

        public PayloadPacket(byte[] data)
        {
            pkt = new Packet(data);
            pkt.ReadPacketType();
            Type = (PayloadType) pkt.ReadUInt8();

            pkt.FinishReading();
        }

        public PayloadPacket()
        {
            pkt = new Packet(PacketType.Payload);
        }

        public byte[] Build()
        {
            pkt.WriteUInt8((byte) Type);

            return pkt.Finalize();
        }
    }
}